<?php
declare (strict_types = 1);
namespace app\course\model\video\admin;

use app\course\model\base\CourseSection as BaseCourseSection;
use app\course\model\video\CourseSectionVideo;

/**
 * 点播课程待审核--后台管理
 */
class ExamineVideoSection extends BaseCourseSection
{
    /**
     * 全局查询范围
     * @var [type]
     */
    protected $globalScope = ['last'];


    /**
     * 课时的最后一级
     * Author   Martinsun<syh@sunyonghong.com>
     * Date 2020-06-10
     * @param    [type]                         $query [description]
     * @return   [type]                                [description]
     */
    public function scopeLast($query)
    {
        $query->where('__TABLE__.is_last',1);
    }

    public function courseData()
    {
        return $this->belongsTo(CourseSectionVideo::class, 'course_data_id')->append(['data_type_text'])->with(['attachBase']);
    }

    /**
     * 关联的课程
     * Author   Martinsun<syh@sunyonghong.com>
     * Date 2020-06-09
     * @return   [type]                         [description]
     */
    public function video()
    {
        return $this->belongsTo(Video::class, 'course_id');
    }
}
